package cj.web.yc.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.yc.domain.StackRoomItem;

/**
 * 
 * @author 
 *
 */
@DAO
public interface StackRoomItemDAO{
	
	@SQL("SELECT * FROM StackRoomItem WHERE deleteFlag=1 #if(:t.descs != null){ AND descs LIKE '%##(:t.descs)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<StackRoomItem> query(@SQLParam("t") StackRoomItem stackRoomItem);
		
	@SQL("SELECT count(1) FROM StackRoomItem WHERE deleteFlag=1 #if(:t.descs != null){ AND descs LIKE '%##(:t.descs)%' } ")
    int querySize(@SQLParam("t") StackRoomItem stackRoomItem);
    
    @SQL("SELECT * FROM StackRoomItem WHERE id=:1")
    StackRoomItem queryById(int id);
    
    @SQL("INSERT INTO StackRoomItem ("
			        		+ "categoryId,"
			        		+ "stackRoomId,"
			        		+ "descs,"
			        		+ "carouselImage,"
			        		+ "url,"
			        		+ "orderNo,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt"
							+") VALUES ("
							+ ":t.categoryId,"
							+ ":t.stackRoomId,"
							+ ":t.descs,"
							+ ":t.carouselImage,"
							+ ":t.url,"
							+ ":t.orderNo,"
							+ "1,"
							+ ":t.createUser,"
							+ "now(),"
							+ ":t.updateUser,"
							+ "now()"
					+")")
    void create(@SQLParam("t") StackRoomItem stackRoomItem);
	
	@SQL("UPDATE StackRoomItem SET "
	    			        + "categoryId=:t.categoryId,"
	    			        + "stackRoomId=:t.stackRoomId,"
	    			        + "descs=:t.descs,"
	    			        + "carouselImage=:t.carouselImage,"
	    			        + "url=:t.url,"
	    			        + "orderNo=:t.orderNo,"
	    			        + "updateUser=:t.updateUser,"
	    			        + "updateAt=now()"
							+ " WHERE id=:t.id")
    void update(@SQLParam("t") StackRoomItem stackRoomItem);
    
    @SQL("UPDATE StackRoomItem SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}